package com.one.common.manager.imageupload;

import android.content.Context;

/**
 * Author：zhulunjun
 * Time：2017/9/25
 * description：文件上传管理，可更换，不影响调用
 */

public class UploaderManager {
    private static IUploader innerUploader;
    private static IUploader externalUploader;

    public static void setUploader(IUploader uploader) {
        if (externalUploader == null && uploader != null) {
            externalUploader = uploader;
        }
    }

    public static IUploader getUploader(Context context) {
        if (innerUploader == null) {
            synchronized (UploaderManager.class) {
                if (innerUploader == null) {
                    if (externalUploader != null) {
                        innerUploader = externalUploader;
                    } else {
                        innerUploader = new QINiuUploader(context);
                    }
                }
            }
        }
        return innerUploader;
    }
}
